<?

include_once('lib/utf8_functions/utf8.php');

function ptal_modifier_truncate($string,$length=100,$etc='...',$break_words = false)
{
    if ($length == 0)
        return '';

    if (UTF8::strlen($string) > $length) 
    {
        if (!$break_words)
            $string = preg_replace('/\s+?(\S+)?$/', '', UTF8::substr($string, 0, $length+1));
            
        return UTF8::substr($string, 0, $length).$etc;
    } else
        return $string;
}
